package com.huaxin.actions.student;

import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;

import com.huaxin.domain.StudentEntity;
import com.huaxin.service.StudentService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 学生根据学号登录的Action
 * 
 * @author 薛琪
 * 
 */
@ParentPackage("json-default")
@Results({ @Result(name = "success", type = "json") })
public class LoginAction extends ActionSupport {
	private String userNum;

	private StudentEntity studentEntity;

	@Autowired
	private StudentService studentService;

	@Override
	public String execute() throws Exception {
		userNum = userNum.trim();// 去除空格
		studentEntity = studentService.queryStudentByUserNum(userNum);
		return SUCCESS;
	}

	@JSON(serialize = false)
	public String getUserNum() {
		return userNum;
	}

	public void setUserNum(String userNum) {
		this.userNum = userNum;
	}

	public StudentEntity getStudentEntity() {
		return studentEntity;
	}

	public void setStudentEntity(StudentEntity studentEntity) {
		this.studentEntity = studentEntity;
	}

	@JSON(serialize = false)
	public StudentService getStudentService() {
		return studentService;
	}

	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}

}
